<?php
class ApplicationConfig implements Config{
	
	const CONFIG_FILE = "config.ini";
	const VERSION = "version";
	const NAME = "name";
	/**
	 * ApplicationConfig instance here ...
	 * @var ApplicationConfig
	 */
	private static $_instance;
	/**
	 * ApplicationConfig array
	 * @var array
	 */
	private $_config;
	/**
	 * Config Path.
	 * @var string
	 */
	private $_path;
	
	private function __construct(){
		$this->_path = APPLICATION_PATH . SLASH . ApplicationConfig::CONFIG_FILE;
		if(!file_exists($this->_path)){
			Log::error("ApplicationConfig", "Resource " . $this->_path . ' not found!');
			if(Configuration::DEBUG_MOD)
				throw new ConfigException("Resource " . $this->_path . ' not found!');
		}
		$this->_config = parse_ini_file($this->_path);
	}
	/**
	 * (non-PHPdoc)
	 * @see library/Config/Config::getConfig()
	 */
	public function getConfig($name){
		return isset($this->_config[$name])?$this->_config[$name]:STRING_EMPTY;
	}
	
	/**
	 * 
	 * Get ApplicationConfig Instance.
	 * @return ApplicationConfig
	 */
	public static function getInstance(){
		if(!self::$_instance){
			self::$_instance = new ApplicationConfig();
		}
		return self::$_instance;
	}
}